(ns com.jeff.tracer.quadratic)

(def determinant
  (fn [a b c]
    (- (* b b) (* 4 a c))))

(def quad-helper #(/ (%4 (* -1 %2) (Math/sqrt (determinant %1 %2 %3))) (* 2 %1)))

(def quadratic
  (fn [a b c]
    (let [det (determinant a b c)]
      (cond
        (< det 0) (list)
        (= det 0) (list (/ (* -1 b) (* 2 a)))
        :else (list (quad-helper a b c -) (quad-helper a b c +))))))
